<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="./plugins/vue/dist/vue.min.js"></script>

    <script type="text/javascript" src="./plugins/axios/dist/axios.min.js"></script>

    <script type="text/javascript" src="./plugins/vue/common.js"></script>

</head>
<body>
<div id="app">欢迎您的登录</div>
</body>

<script type="text/javascript">
    new Vue({
        el:"#app",

        mounted() {
            //获取浏览器上面的参数
            let param = GetRequest();
            //发送请求获取token
            this.$http.post("/wechat/accesstoken", param).then((res => {
                //进行解构
                let {success, msg, result} = res.data;
                //如果result.url 有值就进行跳转
                if (result.url){
                    //跳转到绑定页面
                    location.href = result.url;
                }else {
                    //存储到本地
                    localStorage.setItem("token", result.token);
                    localStorage.setItem("loginUser", JSON.stringify(result.loginUser));//转化为json字符串
                    //result.url没有返回值为null，直接跳转到首页
                    location.href = "/index.html";
                }
            }));
        }

    });
</script>

</html>